package com.epoint.rabbitmq;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *  rabbitmq
 * @author wangchao
 */
@Component
public class RabbitComponent {

	@Autowired
	private AmqpTemplate amqpTemplate;

	/**
	 * 发送消息
	 * @param msg
     */
	public void send(String msg) {
		this.amqpTemplate.convertAndSend("epoint.queue", msg);
	}

	/**
	 * 监听消息
	 * @param text
     */
	@RabbitListener(queues = "epoint.queue")
	public void receiveQueue(String text) {
		System.out.println("接受到：" + text);
	}

}
